package com.ccb.lms.dao;

import com.ibatis.sqlmap.client.SqlMapClient;

import java.sql.SQLException;
import java.util.List;

import com.ccb.lms.model.Appoint;
import com.ccb.lms.model.User;
import com.ccb.lms.util.BasePage;
import com.ibatis.sqlmap.client.SqlMapClient;

public class AppointDAO implements IAppointDAO {
	private SqlMapClient sqlMapClient = null;

	public SqlMapClient getSqlMapClient() {
		return sqlMapClient;
	}

	public void setSqlMapClient(SqlMapClient sqlMapClient) {
		this.sqlMapClient = sqlMapClient;
	}
	public boolean insertAppoint(Appoint appoint) throws SQLException {
		// TODO Auto-generated method stub
		sqlMapClient.insert("appoint.insertAppoint", appoint);
		return true;
	}

	public boolean deleteAppoint(Integer appointNO) throws SQLException {
		// TODO Auto-generated method stub
		sqlMapClient.delete("appoint.deleteAppoint", appointNO);
		return true;
	}

	public boolean updateAppoint(Appoint appoint) throws SQLException {
		// TODO Auto-generated method stub
		sqlMapClient.update("appoint.updateAppoint", appoint);
		return true;
	}

	@SuppressWarnings("unchecked")
	public List<Appoint> getAllAppoints() throws SQLException {
		// TODO Auto-generated method stub
		return sqlMapClient.queryForList("appoint.getAllAppoints");
	}

	public Appoint getAppointByNO(Integer appointNO) throws SQLException {
		// TODO Auto-generated method stub		
		return (Appoint) sqlMapClient.queryForObject("appoint.getAppointByNO", appointNO);
	}

	public int getAppointCount() throws SQLException {
		// TODO Auto-generated method stub
		return (Integer) sqlMapClient.queryForObject("appoint.recordCount");
	}

	public BasePage getBasePage(int currentPage, int showRecordNum)
			throws SQLException {
		// TODO Auto-generated method stub
		return new BasePage(currentPage, getAppointCount(), showRecordNum);
	}

	@SuppressWarnings("unchecked")
	public List<Appoint> getAppointByPage(BasePage basePage) throws SQLException {
		// TODO Auto-generated method stub
		return sqlMapClient.queryForList("appoint.getAppointByPage", basePage);
	}
}
